package com.runa.rccprotocol.analysis.En13757.decoder;

import com.runa.protocol.enums.ByteOrder;
import com.runa.protocol.util.ByteUtil;

/**
 * @author diandian
 * @Date 2021/11/10 16:02
 */
public class Dif_Function_Int implements Dif_Function {
    @Override
    public Integer handle(byte[] dataByte, int index, int length) {
        switch (length) {
            case 1:
                return dataByte[index] & 0xff;
            case 2:
                return ByteUtil.byteToUShort(dataByte, index, ByteOrder.AB);
            case 3:
                //不实现
            case 4:
                return ByteUtil.byteToInt(dataByte, index, ByteOrder.ABCD);
            case 6:
                //不实现
            case 8:
                //不实现
        }
        return 0;
    }

    public static void main(String[] args) {

    }
}